package day_2022_12_to_3.day;

/**
 * @author haomin
 * @date 2022/12/13 22:47
 **/
public class Day12_13_Review {
    class Solution {
        public TreeNode mirrorTree(TreeNode root) {
            if(root == null) return root;
            TreeNode l = root.left;
            TreeNode r = root.right;
            root.left = r;
            root.right = l;
            mirrorTree(root.left);
            mirrorTree(root.right);
            return root;
        }
    }


    class Solution2 {
        public boolean isSymmetric(TreeNode root) {
            if(root == null) return true;
            return isSymmetricHelper(root.left, root.right);
        }
        private boolean isSymmetricHelper(TreeNode l, TreeNode r) {
            if(l == null && r == null) return true;
            if(l == null || r == null) return false;
            return l.val == r.val && isSymmetricHelper(l.left, r.right) && isSymmetricHelper(l.right, r.left);
        }
    }


}